import requests

server_url = 'http://0.0.0.0:8080/core/sensor/'


def add_sensor():
    data = {'name': 'cui1', 'code':'12', 'dis_order':1,
            'description': 'ddd', 'icon':'hh', 'sensor_type_id':1,
            'sensor_group_id':1,
            }
    url = server_url + 'add/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(r.json())


def edit_sensor():
    data = {'name': 'cui5', 'code':'1323', 'dis_order':1,
            'description': 'dddh', 'icon':'hh', 'id':4
            }
    url = server_url + 'edit/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(r.json())


def del_sensor():
    data = {'id': 4}
    url = server_url + 'del/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(r.json())


add_sensor()
# edit_sensor()
# del_sensor()